// 这里配置webpack
const { resolve } = require('path');
const { webpack, ProvidePlugin } = require("webpack");
// const  Baseurl='http://10.33.33.102:8556'
// const  Baseurl='http://10.20.193.62:8556'
const  Baseurl='http://10.20.193.62:8556'
// const  Baseurl='http://10.33.32.189:8551'
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
  transpileDependencies: true,
  publicPath: "/",
  outputDir: "dist",
  assetsDir: "static",

  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve(__dirname, "src"),
      },
      fallback: {
        //"url": require.resolve("url/"),
        buffer: require.resolve("buffer"),
        stream: require.resolve("stream-browserify"),
      },
    },

    experiments: {
      topLevelAwait: true,
    },
    
    plugins: [
      new MonacoWebpackPlugin(),
      new ProvidePlugin({
        // process: 'process/browser',
        Buffer: ["buffer", "Buffer"],
      }),
    ],
  },

  chainWebpack: (config) => {
    let title = "EAP管理系统"; //配置页面标签title，和index.html的title是对应配置的
    config.plugin("html").tap((agrs) => {
      agrs[0].title = title;
      return agrs;
    });
  },

  devServer: {
    proxy: {
      "/webapi": {
        target: `${Baseurl}/api`,
        ws: true,
        changeOrigin: true,
        pathRewrite: { "^/webapi": "" },
      },
      "/idehtml": {
        target: `${Baseurl}`,
        ws: true,
        changeOrigin: true,
        pathRewrite: { "^/idehtml": "" },
      },
      "": {
        target: `${Baseurl}`,
      },
    },
  },
};
